package com.xfxz.merchant.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.xfxz.merchant.R;

import java.util.List;

import butterknife.BindView;
import butterknife.BindViews;
import butterknife.ButterKnife;

/**
 * Created by xunianshi on 2017/2/17.
 */

public class AttentionAdapter extends XBaseAdapter {

    private Context mContext;
    private List<String> mData;

    public AttentionAdapter(Context context, List data) {
        super(data);
        mContext = context;
        mData = data;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = View.inflate(mContext, R.layout.item_attention_collect_attention, null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        if (position == 0) {
            holder.tvs[0].setVisibility(View.VISIBLE);
            holder.tvs[0].setText("今日");
        } else if (position == 1) {
            holder.tvs[0].setVisibility(View.VISIBLE);
            holder.tvs[0].setText("历史");
        } else {
            holder.tvs[0].setVisibility(View.GONE);
        }
        holder.tvs[1].setText(mData.get(position));
        return convertView;
    }

    public class ViewHolder{
        @BindView(R.id.iv_item_attention_icon)
        public ImageView iv;
        @BindViews({R.id.tv_item_attention_date, R.id.tv_item_attention_name, R.id.tv_item_attention_time})
        public TextView[] tvs;

        public ViewHolder(View convertView) {
            ButterKnife.bind(this, convertView);
        }
    }
}
